<template>
  <div>
    <div class="search">
      <van-button type="primary" size="large" @click="healthSearch"
        >查询疫情防疫</van-button
      >
    </div>
    <div class="content" :style="{ display: isShow }">
      <!-- 出发地 -->
      <div>
        <span class="city_style"
          >出发城市:&nbsp;{{ from_info.city_name }}
        </span>
        <h4>请您使用本地健康码：{{ from_info.health_code_name }}</h4>
        <h3>低风险地区，进入政策描述:</h3>
        <p>
          {{ from_info.low_in_desc }}
        </p>
        <h3>出行政策描述:</h3>
        <p>
          {{ from_info.out_desc }}
        </p>
      </div>
      <!-- 到达地 -->
      <div>
        <span class="city_style">出发城市:&nbsp;{{ to_info.city_name }} </span>
        <h4>请您使用本地健康码：{{ to_info.health_code_name }}</h4>
        <h3>低风险地区，进入政策描述:</h3>
        <p>
          {{ to_info.low_in_desc }}
        </p>
        <h3>出行政策描述:</h3>
        <p>
          {{ to_info.out_desc }}
        </p>
      </div>
    </div>
  </div>
</template>

<script>
import api from "../../api/index";
export default {
  props: ["from", "to"],
  data() {
    return {
      from_info: "",
      to_info: "",
      isShow: "none",
    };
  },
  methods: {
    healthSearch() {
      // console.log("查询中", this.from, this.to);
      api
        .getTravelQuery({
          from: this.from,
          to: this.to,
        })
        .then((res) => {
          // console.log(res.data);
          this.from_info = res.data.result.from_info;
          this.to_info = res.data.result.to_info;
          // console.log(this.from_info);
          // console.log(this.to_info);
        });
      if (this.from !== "" && this.to !== "") {
        this.isShow = "block";
      } else {
        this.isShow = "none";
      }
    },
  },
};
</script>

<style lang="less" scoped>
.search {
  padding: 0.25rem;

  .van-button--primary {
    background: #07c16059;
  }
}
.content {
  background-color: #0000002e;
  border-radius: 0.25rem 0.25rem 0 0;
  padding: 0.25rem;
  font-size: 0.25rem;
  color: #fffc;
  p {
    margin-bottom: 0.25rem;
  }
  h3 {
    color: #19fa7a;
    margin: 0 0 0.25rem 0;
  }
  h4 {
    margin: 0 0 0.25rem 0;
    color: #fff;
    font-weight: normal;
  }
  .city_style {
    display: block;
    color: #fff;
    margin-bottom: 0.25rem;
    font-size: 0.3rem;
    font-weight: 700;
  }
}
</style>
